<?php
/* 必要数据效验 */
function CheckMustData($arr){
	foreach ($arr as $key => $value) {
		if($value==null||$value==''){
			ApiResult(301);
		}
	}
	return true;
}
/* 全局失败返回 */
function ApiResult($code=300,$data=array()){
	$code_config = C('result_code');
	$reuslt = array(
		'code'=>$code,
		'msg'=>$code_config[$code],
		'data'=>$data
	);
	exit(json_encode($reuslt));
}
/* 发送短信 */
function SendSms($phone,$code){
	$sms_config = C('sms');

	$appId = $sms_config['appid'];
    $templateId = $sms_config['templateId'];
	$options['accountsid']=$sms_config['AccountSid'];
    $options['token']=$sms_config['AuthToken'];
	import("Org.Util.Ucpaas");
	$ucpass = new Ucpaas($options);
    $to = $phone;
    
    $param=$code;
	$arr=$ucpass->templateSMS($appId,$to,$templateId,$param);
    if (substr($arr,21,6) == 000000) {
    	return true;
    }else{
        return false;
    }
}
?>